/**
 * 
 */
package cn.gov.msa.ws;


import javax.jws.WebService;
import cn.gov.msa.collection.SmsService;
import cn.gov.msa.util.PropertiesTools;
import cn.gov.msa.util.WebServiceTools;
import net.sf.json.JSONObject;


@WebService(endpointInterface = "cn.gov.msa.ws.GahService")
public class GahServiceImpl implements GahService {

	private static String todourl  = PropertiesTools.readProperties("todo.url");
 

	public String gTasksUpdateOrAdd(String param) throws Exception {
		if("1".equals(PropertiesTools.readProperties("project.4atodo"))) {
			System.out.println("gahCSP-gTasksUpdateOrAdd:"+param);
			return WebServiceTools.getDataByUrl(todourl, "gTasksUpdateOrAdd", param);
		}else {
			return JSONObject.fromObject("{'result':'1'}").toString();
		}
	}


	/**
	 * @param {"phone":"","message":""}
	 */
	@Override
	public String sms(String param) {
		String result = "";
		try {
			JSONObject messageJson = JSONObject.fromObject(param);
			result = SmsService.sendSingleMessage(messageJson.getString("phone"), messageJson.getString("message"));
		} catch (Exception e) {
			result = "{\"result\":\"0\",\"info\":\"短信发送接口异常："+e.getMessage()+"\"}";
		}
		return result;
	}
	
	
}
